#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

double calc(double a,double b)
{
    double x=4*b;
    double t=a*b;
    if(b==0)
    {
        return 1;
    }
    else if(a==0)
    {
        return 0.5;
    }
    if(x<=a)
    {
        return  ((2*a-x)*b/2+t)/(2*a*b);
    }
    else
    {
        double y=a/4;
        return (a*y/2+t)/(2*a*b);
    }
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        double a,b;
        cin>>a>>b;
        printf("%.7f\n",calc(a,b));
    }
	return 0;
}
